package com.sjc.lesson01.function;

import com.sjc.lesson01.domain.WordAndCount;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.util.Collector;

public class SplitWord implements FlatMapFunction<String, WordAndCount> {

    @Override
    public void flatMap(String line, Collector<WordAndCount> collector) throws Exception {
        String[] fields = line.split(",");
        for (String word : fields) {
            collector.collect(new WordAndCount(word, 1));
        }
    }
}
